{% extends 'user/layout.html.twig' %}

{% block title %}{{ parent() }}{% endblock %}

{% set pageNav = 'favorited' %}

{% block main %}
  <ul class="nav nav-pills mbl">
    <li {% if app.request.get('goodsType')|default('course') == 'course' %}class="active"{% endif %}><a href="{{ path('user_favorited', {id:user.id, goodsType: 'course'}) }}">{{'site.default.course'|trans}}</a></li>
    <li {% if app.request.get('goodsType')|default('course') == 'classroom' %}class="active"{% endif %}><a href="{{ path('user_favorited', {id:user.id, goodsType: 'classroom'}) }}">{{'site.default.classroom'|trans}}</a></li>
  </ul>
  <div class="course-list course-list-new">
    <div class="row">
      {% for favorite in favorites if favorite %}
        {% if favorite.targetType == 'course' %}
          {% set courseSet = data('CourseSet',{ id: favorite.targetId} ) %}
          {% if courseSet.id|default(null) %}
            <div class="col-lg-3 col-md-4 col-xs-6 course-item-wrap">
              {% include 'course/widgets/course-grid-new.html.twig' with { courseSet: courseSet } %}
            </div>
          {% endif %}
        {% elseif favorite.targetType == 'openCourse' %}
          {% set course = data('OpenCourse',{courseId:favorite.targetId})|default(null) %}
          {% if course %}
            <div class="col-lg-3 col-md-4 col-xs-6 course-item-wrap">
              {% include 'open-course/widget/open-course-grid.html.twig' %}
            </div>
          {% endif %}
        {% elseif favorite.targetType == 'goods' %}
          {% set goods = data('Goods', {id: favorite.targetId}) %}
          {% if goods %}
            <div class="col-lg-3 col-md-4 col-xs-6 course-item-wrap">
              {% include 'goods/goods-grid.html.twig' with { goods: goods} %}
            </div>
          {% endif %}
        {% endif %}
      {% else %}
        <div class="empty">{{ 'user.homepage.favorite_goods.empty'|trans }}</div>
      {% endfor %}
    </div>
  </div>
  <nav class="text-center">
    {{ web_macro.paginator(paginator) }}
  </nav>
{% endblock %}